package com.toaa.crazymath.controller;

import com.toaa.crazymath.Constant.GameMode;

public class OperatorFactory {
	
	private static OperatorFactory sInstance = null;
	
	public static OperatorFactory getInstance() {
		if (sInstance == null) {
			sInstance = new OperatorFactory();
		}
		return sInstance;
	}
	
	public BaseOperator createOperator(int modeID) {
		BaseOperator result = null;
		if (GameMode.ADDITION.ordinal() == modeID) {
			result = new AdditionOperator(); 
		} else if (GameMode.SUBTRACTION.ordinal() == modeID) {
			result = new SubtractionOperator();
		} else if (GameMode.MULTIPLICATION.ordinal() == modeID) {
			result = new MultiOperator();
		} else if (GameMode.DIVISION.ordinal() == modeID) {
			result = new DivisionOperator();
		}
		return result;
	}
}
